var should = require('should');
var async = require('async');
var achieveHandler = require('../../../app/servers/user/handler/achieveHandler');
var config = require('../../config');
var PlayerManager = require('../../../app/libs/playerManager');
var configUtil = require('../../../app/util/configUtil');
var analyze = require('kc-analyze');
var _ = require('lodash');
var checkModel = require('../../../app/models/checkModel');

suite('测试achieveHandler', function () {
    var player_manager = new PlayerManager(config.role_id);
    setup(function (done) {
        async.waterfall(
            [
                function (cb) {
                    player_manager.getAllModel(cb);
                },
                function (cb) {
                    // player_manager.achieve.complete_task_list = [];
                    // player_manager.achieve.static_list = {
                    //     1: {
                    //         total_gold: 100000000
                    //     }
                    // };
                    // player_manager.achieve.addTask(10101);
                    // player_manager.save();
                    cb();
                },
                function (cb) {
                    player_manager.save(cb);
                }
            ],
            function (err) {
                done();
            }
        );
    });

    setup(function (done) {
        var analyze_config = configUtil.load('analyze');
        var game_config = configUtil.load('game');
        analyze.initialize({
            host: analyze_config.host,
            server_id: game_config.server_id
        });
        done();
    });

    suite('reward', function () {
        test('获取任务奖励', function (done) {
            var msg = {};
            var session = {};
            session.uid = config.role_id;

            var achieve_Handler = new achieveHandler();
            achieve_Handler.reward(msg, session, function (err, res) {
                done();
            });
        });

        test('获取任务奖励', function (done) {
            var msg = {
                achieve_id: config.achieve_id
            };
            var session = {};
            session.uid = config.role_id;

            var achieve_Handler = new achieveHandler();
            achieve_Handler.reward(msg, session, function (err, res) {
                done();
            });
        });
    });
});
